package com.example.service.impl;

import com.example.mapper.OrderMapper;
import com.example.pojo.OrdSearch;
import com.example.pojo.Order;
import com.example.pojo.PageBean;
import com.example.pojo.Supplier;
import com.example.service.OrderService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public PageBean getOrder(OrdSearch order, Integer page, Integer pageSize) {
        //设置分页参数
        PageHelper.startPage(page,pageSize);
        List<OrdSearch> list = orderMapper.getOrder(order);
        Page<OrdSearch> p= (Page<OrdSearch>) list;
        PageBean pageBean=new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }

    @Override
    public void changeOrder(Order order) {
        orderMapper.changeOrder(order);
    }

    @Override
    public void deleteOrder(String id) {
        orderMapper.deleteOrder(id);
    }

    @Override
    public Integer addOrder(Order order) {
         orderMapper.addOrder(order);
         return  order.getOrdCode();
    }
}
